import { typeStatus } from "@/interface/public";

export const useTitle = () => {
  let customTitle = ref("");

  const setTitle = (title: string, status: typeStatus["operationFlag"]) => {
    const { ADD, PARTICULAR, EDIT } = OPERATION_FLAG;
    switch (status) {
      case ADD:
        customTitle.value = "新增-" + title;
        break;
      case EDIT:
        customTitle.value = "编辑-" + title;
        break;
      case PARTICULAR:
        customTitle.value = title + "-详情";
        break;
      default:
        customTitle.value = title;
    }

    uni.setNavigationBarTitle({
      title: customTitle.value
    });
  };
  return {
    customTitle,
    setTitle
  };
};
